//===============================================================================
// Microsoft patterns & practices Enterprise Library Contribution
// Mapping Application Block
//===============================================================================

using System.Configuration;
using Microsoft.Practices.EnterpriseLibrary.Common.Configuration;
using Microsoft.Practices.EnterpriseLibrary.Common.Configuration.ObjectBuilder;
using Microsoft.Practices.EnterpriseLibrary.Common.Configuration.Unity;
using EntLibContrib.Mapping.Configuration.Unity;
using EntLibContrib.Mapping.Maps;

namespace EntLibContrib.Mapping.Configuration
{
	/// <summary>
	/// Configuration data defining MapData. This configuration section defines the name and type
	/// of the IMap class
	/// </summary>
	[Assembler(typeof(MapAssembler))]
	[ContainerPolicyCreator(typeof(MapPolicyCreator))]
	public class MapData : NameTypeConfigurationElement
	{
		#region Fields
		private const string columnNameProperty = "columnName";
		#endregion

		#region Properties
		/// <summary>
		/// Gets or sets the mapped DataSet table column name.
		/// </summary>
		/// <value>The dataset table column name.</value>
		[ConfigurationProperty(columnNameProperty, IsRequired = false)]
		public string ColumnName
		{
			get { return (string)base[columnNameProperty]; }
			set { base[columnNameProperty] = value; }
		}
		#endregion

		#region Construction
		/// <summary>
		/// Initializes a new instance of the <see cref="MapData"/> class.
		/// </summary>
		public MapData()
		{
		}

		/// <summary>
		/// Initializes a new instance of the <see cref="MapData"/> class.
		/// </summary>
		/// <param name="name">The map name.</param>
		/// <param name="columnName">The mapped DataSet table column name.</param>
		public MapData(string name, string columnName)
			: base(name, typeof(Map))
		{
			this.ColumnName = columnName;
		}
		#endregion
	}
}
